<template>
  <button @click="add">添加</button>
  <button @click="remove">删除</button>
  <button @click="shiffNum">洗牌</button>
  <TransitionGroup name="list" tag="p">
    <span v-for="item in items" :key="item" class="list-item">
      {{ item }}
    </span>
  </TransitionGroup>

  <child />
</template>

<script setup>
import child from "./child.vue";
import { ref, reactive, onErrorCaptured } from "vue";
import _ from "lodash";
const items = ref([1, 2, 3, 4, 5, 6, 7, 8, 9]);
const randomIndex = () => Math.floor(Math.random() * items.value.length);
const add = () => {
  items.value.splice(randomIndex(), 0, items.value.length + 1);
};
const remove = () => items.value.splice(randomIndex(), 1);
const shiffNum = () => (items.value = _.shuffle(items.value));

onErrorCaptured((err, instance, info) => {
  console.log(err, instance, info, "onError555555555555Captured");
});
const lists = reactive({
  name: "qwe",
  age: 20,
});
</script>

<style scoped>
.list-item {
  display: inline-block;
  margin-right: 10px;
}
.list-enter-from,
.list-leave-to {
  opacity: 0;
  transform: translateY(-30px);
}
.list-move,
.list-enter-active,
.list-leave-active {
  transition: all 1s ease;
}
.list-leave-active {
  position: absolute;
}
</style>
